package Day08_20;

public class Test_CorrectionStop {
    public static void main(String[] args) {
        /*
        t.stop() 强行终止程序，可能会丢失数据
        写一个布尔标记
         */
        MyThread04 t4 = new MyThread04();
        t4.setName("t4");
        t4.start();
        t4.run = false;

        try {
            Thread.currentThread().sleep(1000*5);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        t4.run = false;
    }
}
class MyThread04 extends Thread{
 //   @Override
    boolean run = true;
    public void run() {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName() + "->" + i);
                if (run) {
//                    try {
//                        Thread.currentThread().sleep(2000);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
                } else {
                    System.out.println("MyTread04线程要结束了！！！！！！");
                    return;
                }
            }
    }
}
